package com.boruiimage.demo.controller;

import com.boruiimage.demo.doMain.ResultModel;
import com.boruiimage.demo.repository.imgInfoDao;
import com.boruiimage.demo.utils.AES;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class imgInfoController {
    @Autowired
    imgInfoDao ido;
    @RequestMapping("/selectImgInfo")
    public ResultModel show(@RequestBody Map<String,String>map){
        PageHelper.startPage((Integer.parseInt(map.get("pageNum"))-1)*15,15);
        return ido.selectByuserName(map.get("userName"));
    }
    @RequestMapping("/selectImgInfoByPc")
    public ResultModel show(@RequestParam(value = "userName")String userName,@RequestParam(value = "pageIndex") Integer pageIndex){
        PageHelper.startPage(pageIndex,15);
        ResultModel resultModel=ido.selectByuserName(AES.encrypt(userName));
        resultModel.setErrcode(ido.selectImginfoCount(AES.encrypt(userName)));
        return resultModel;
    }
}
